<template>
  <div>
    <el-dialog
      title="编辑案例"
      :visible.sync="show"
      :before-close="close"
      width="40%"
    >
      <div class="formBox">
        <div class="formHead">过往成功防治案例</div>
        <div class="formWhite">
          <div class="left"><span class="red">*</span>小区名称</div>
          <div class="right">
            <el-input
              v-model="submitForm.communityName"
              placeholder="请输入"
              size="small"
            ></el-input>
          </div>
        </div>
        <div class="formWhite">
          <div class="left"><span class="red">*</span>防治面积(m²)</div>
          <div class="right">
            <el-input
              v-model="submitForm.controlArea"
              placeholder="请输入"
              size="small"
            ></el-input>
          </div>
        </div>
        <div class="formWhite">
          <div class="left"><span class="red">*</span>防治方案</div>
          <div class="right">
            <el-input
              v-model="submitForm.controlPlan"
              placeholder="请输入"
              size="small"
            ></el-input>
          </div>
        </div>
        <div class="formWhite">
          <div class="left"><span class="red">*</span>效果评估</div>
          <div class="right">
            <el-input
              v-model="submitForm.effectEvaluation"
              placeholder="请输入"
              size="small"
            ></el-input>
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="enSure" size="small">确定</el-button>
        <el-button type="primary" plain @click="close" size="small"
          >取消</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    show: {
      type: Boolean,
      default: false,
    },
    detailForm: {
      default: {},
    },
  },
  data() {
    return {
      submitForm: {
        communityName: "",
        controlArea: "",
        controlPlan: "",
        effectEvaluation: "",
      },
    };
  },
  created() {
    console.log(this.detailForm);

    if (this.detailForm) {
      this.submitForm = { ...this.detailForm };
    }
  },
  methods: {
    close() {
      this.$emit("closeMsg");
    },
    enSure() {
      if (!this.submitForm.communityName) {
        this.$modal.msgWarning("小区名称不能为空！");
      } else if (!this.submitForm.controlArea) {
        this.$modal.msgWarning("防治面积不能为空！");
      } else if (!this.submitForm.controlPlan) {
        this.$modal.msgWarning("防治方案不能为空！");
      } else if (!this.submitForm.effectEvaluation) {
        this.$modal.msgWarning("效果评估不能为空！");
      } else {
        console.log(this.submitForm, "this.submitForm");
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.formBox {
  .left {
    display: inline-block;
    height: 44px;
    line-height: 44px;
    width: 140px;
    padding-right: 15px;
    border-left: 1px solid #e4e4dc;
    border-right: 1px solid #e4e4dc;
    font-family: MicrosoftYaHei;
    font-size: 12px;
    color: #303133;
    text-align: right;
    vertical-align: top;
  }
  .right {
    display: inline-block;
    width: calc(100% - 140px);
    height: 44px;
    border-right: 1px solid #e4e4dc;
    padding: 6px 15px;
    .el-select {
      width: 100% !important;
    }
    .el-input {
      width: 100% !important;
    }
  }
  .formHead {
    width: 100%;
    height: 44px;
    background-color: #73879c;
    height: 44px;
    line-height: 44px;
    text-align: center;
    font-family: MicrosoftYaHei, MicrosoftYaHei;
    font-weight: bold;
    font-size: 12px;
    color: #ffffff;
  }
  .formWhite {
    width: 100%;
    height: 44px;
    background-color: #fff;
    border-bottom: 1px solid #e4e4dc;
  }
  .area {
    .areaLeft {
      width: 40% !important;
      margin-right: 10px;
    }
    .areaRight {
      width: calc(60% - 10px) !important;
    }
  }
  .formGray {
    width: 100%;
    height: 44px;
    background-color: #eef0f2;
    border-bottom: 1px solid #e4e4dc;
  }
}
.red {
  color: red;
  margin-right: 2px;
  vertical-align: top;
}
::v-deep .el-dialog__header {
  border-bottom: 1px solid #e9e9ec;
}
::v-deep .el-dialog__footer {
  border-top: 1px solid #e9e9ec;
}
</style>
